//
//  BusLineCell.m
//  Bus_iPhone
//
//  Created by antunnel on 12-7-2.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "BusLineCell.h"

@interface BusLineCell (Private)

-(void)setViewSelect:(BOOL)selected animated:(BOOL)animated;

@end

@implementation BusLineCell

@synthesize busImgView=_busImgView;
@synthesize busLineLabel=_busLineLabel;
@synthesize busInfoTextView=_busInfoTextView;

-(void)dealloc{

    [_busInfoTextView release];
    [_busImgView release];
    [_busLineLabel release];
    [super dealloc];
}


+(CGFloat)defaultHeight{

    return 85.0f;
}

-(void)setBusImgView:(UIImageView *)busImgView{

    _busImgView=busImgView;
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        _busImgView=[[UIImageView alloc]initWithFrame:CGRectMake(10.0f, 5.0f, 40.0f, 40.0f)];
        _busImgView.backgroundColor=[UIColor clearColor];
        [self.contentView addSubview:_busImgView];
        
        _busLineLabel=[[UILabel alloc]initWithFrame:CGRectMake(60.0f, 5.0f, self.contentView.frame.size.width-70.0f, 20.0f)];
        _busLineLabel.backgroundColor=[UIColor clearColor];
        _busLineLabel.autoresizingMask=UIViewAutoresizingFlexibleWidth;
        [self.contentView addSubview:_busLineLabel];
        
        _busInfoTextView=[[UILabel alloc]initWithFrame:CGRectMake(65.0f, 25.0f, self.contentView.frame.size.width-80.0f, 55.0f)];
        _busInfoTextView.font=[UIFont systemFontOfSize:12.0f];
        _busInfoTextView.backgroundColor=[UIColor clearColor];
        _busInfoTextView.numberOfLines=0;
        [self.contentView addSubview:_busInfoTextView];
        
        UIImage *pressImg=[UIImage imageNamed:@"buddy_list_press.png"];
        UIImageView *pressView=[[UIImageView alloc]initWithImage:pressImg];
        self.selectedBackgroundView=pressView;
        [pressView release];
        
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    [self setViewSelect:selected animated:animated];
    // Configure the view for the selected state
}


-(void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated{

    [super setHighlighted:highlighted animated:animated];
    
    [self setViewSelect:highlighted animated:animated];
}

-(void)setViewSelect:(BOOL)selected animated:(BOOL)animated{

    if (selected) {
        _busInfoTextView.textColor=[UIColor whiteColor];
        _busLineLabel.textColor=[UIColor whiteColor];
    }else {
        _busInfoTextView.textColor=[UIColor blackColor];
        _busLineLabel.textColor=[UIColor blackColor];
    }
}
@end
